<?php

$api = app('Dingo\Api\Routing\Router');
$moduleName = 'User';

// 平台后台api
$api->version('v1', ['prefix' => 'admin-api', 'namespace' => 'Modules\\'.$moduleName.'\Http\Controllers\Admin\V1'], function ($api) {
	$allMethod = ['index', 'show', 'store', 'update', 'destroy'];

	// 用户增删改查
	$api->resource('users', "UserController", ['only' => $allMethod]);

	// VIP会员增删改查
	$api->resource('vip-users', "VipUserController", ['only' => $allMethod]);

	// VIP套餐增删改查
	$api->resource('vip-skus', "VipSkuController", ['only' => $allMethod]);

	// 用户分组相关
	$api->resource('user-groups', "UserGroupController", ['only' => $allMethod]);

	// 检测人数
	$api->post('user-group/check-total', ['uses'=> "UserGroupController@checkUserTotal"]);

	// 设置人群价
	$api->get('/{type}/{uuid}/group-price', ['uses'=> "UserGroupPriceController@index"]);
	$api->post('/{type}/{uuid}/group-price', ['uses'=> "UserGroupPriceController@store"]);

	$api->get('/status-total/user', ['uses'=> "UserController@statusTotal"]);

	// 更改用户积分
	$api->patch('/users/{uuid}/score', ['uses'=> "UserScoreController@update"]);

	// 更改用户红包余额
	$api->patch('/users/{uuid}/redpack', ['uses'=> "UserRedpackController@update"]);

	$api->post('/export/users', ['uses'=> "UserExportController@store"]);
	$api->post('/export/user-total', ['uses'=> "UserExportController@total"]);
	$api->get('/export/users/{uuid}', ['uses'=> "UserExportController@show"]);
});

// 租户api
$api->version('v1', ['prefix' => 'tenant-api', 'namespace' => 'Modules\\'.$moduleName.'\Http\Controllers\Tenant\V1'], function ($api) {
	$allMethod = ['index', 'show', 'store', 'update', 'destroy'];
});

// 普通用户api
$api->version('v1', ['namespace' => 'Modules\\'.$moduleName.'\Http\Controllers\Client\V1'], function ($api) {
	$allMethod = ['index', 'show', 'store', 'update', 'destroy'];

	// ---- H5 ------
	// H5手机号登陆
	$api->post('login/h5/with-phone-code', ['uses'=> "H5Controller@loginWithPhoneCode"]);
	// h5绑定微信
	$api->post('/h5/bind-wechat', ['uses'=> "H5Controller@bindWechat"]);

	// 微信小程序授权登陆
	$api->post('login/with-wechat', ['uses'=> "LoginController@loginWithWechat"]);
	$api->post('login/with-byte-dance', ['uses'=> "LoginController@loginWithByteDance"]);
	// $api->post('login/app/with-wechat', ['uses'=> "LoginController@loginWithAppByWechat"]);
	$api->post('login/app/with-apple-id', ['uses'=> "AppController@loginWithAppleId"]);
	$api->post('login/app/with-tourist', ['uses'=> "AppController@loginWithTourist"]);


	// ----- APP -----
	$api->post('login/app/with-phone-code', ['uses'=> "AppController@loginWithPhoneCode"]);
	$api->post('login/app/with-wechat', ['uses'=> "AppController@loginWithWechat"]);


	//App端绑定微信信息
	$api->post('app/bind-wechat', ['uses'=> "AppController@bindWechat"]);

	// 淘宝/天猫小程序登陆
	$api->post('login/with-taobao', ['uses'=> "LoginController@loginWithTaobao"]);

	$api->post('login/phone-code', ['uses'=> "LoginController@phoneCode"]);

	// 快手登陆
	$api->post('login/kuaishou/miniapp', ['uses'=> "KuaishouController@loginWithMiniapp"]);

	// 支付宝小程序登陆
	$api->post('login/alipay/miniapp', ['uses'=> "AlipayController@loginWithMiniapp"]);

	// 获取当前用户信息
	$api->get('user', ['uses'=> "CurrentUserController@show"]);
    $api->put('user', ['uses'=> "CurrentUserController@update"]);
    $api->post('updateHeadImg', ['uses'=> "CurrentUserController@updateHeadImg"]);

    // 绑定邀请人
	$api->post('/user/bind-inviter', ['uses'=> "CurrentUserController@bindInviter"]);

	$api->delete('user', ['uses'=> "CurrentUserController@destroy"]);

	// 修改手机号 （微信小程序)
	$api->post('/phone-update/with-miniapp', ['uses'=> "CurrentUserController@updatePhoneWithMiniapp"]);
	// 修改手机号 （手机号+验证码)
	$api->post('/phone-update/with-code', ['uses'=> "CurrentUserController@updatePhoneWithCode"]);

	// vip订单预览
	$api->post('vip-order/preview', ['uses'=> "VipPreviewOrderController@store"]);
	// 创建VIP订单
	$api->post('vip-orders', ['uses'=> "VipOrderController@store"]);

	// 获取VIP套餐列表
	$api->get('vip-skus', ['uses'=> "VipSkuController@index"]);

	// 查看人群价是否可用
	$api->get('group-prices/{uuid}', ['uses'=> "GroupPriceController@show"]);

	// 获取我的签到记录
	$api->get('sign-in-records', ['uses'=> "SignInController@index"]);

	// 签到卡获取信息
	$api->get('sign-in-card-info', ['uses'=> "SignInController@cardInfo"]);

	// 进行签到
	$api->post('sign-in', ['uses'=> "SignInController@store"]);

	// 检测用户分组条件
	$api->post('/user-group/check', ['uses'=> "UserGroupController@check"]);

	// 获取签到配置
	$api->get('sign-in/config', ['uses'=> "SignInController@config"]);

	// 获取我的地址
	$api->resource('addresses', "AddressController", ['only' => $allMethod]);
	// 获取某个地址详情
	$api->post('addresses/{uuid}', ['uses'=> "AddressController@update"]);
	// 删除某个地址
	$api->post('addresses/{uuid}/delete', ['uses'=> "AddressController@destroy"]);
});